package com.burgeon.backend.SHOPBACKEND.controller;

import com.burgeon.backend.SHOPBACKEND.entity.MailType;
import com.burgeon.backend.SHOPBACKEND.service.BackendSystemService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("shopbackent/system")
public class BackendSystemController extends BaseController {

    @Autowired
    private BackendSystemService backendSystemService;

    @RequestMapping("tryApply")
    public ResponseResult<Void> tryApply(String name,String phone ,String corporation) {
        backendSystemService.tryApply(name,phone,corporation);
        return new ResponseResult<>(SUCCESS);
    }

    @RequestMapping("mainImg")
    public ResponseResult<List<String>> mainImg() {
        List<String> data = backendSystemService.mainImg();
        return new ResponseResult<List<String>>(SUCCESS,data);
    }

    @RequestMapping("mapkey")
    public ResponseResult<String> getMapKey(String token) {

        String data = backendSystemService.getMapKey(token);
        return new ResponseResult<String>(SUCCESS,data);
    }

    @RequestMapping("upMailType")
    public ResponseResult<Void> delMailType(MailType mailType) {

        backendSystemService.upMailType(mailType);
        return new ResponseResult<>(SUCCESS);
    }


    @RequestMapping("createlMailType")
    public ResponseResult<Void> delMailType(MailType mailType, String account) {
        mailType.setToken(account);
        backendSystemService.createMailType(mailType);
        return new ResponseResult<>(SUCCESS);
    }

    @RequestMapping("delMailType")
    public ResponseResult<Void> delMailType(String id) {
        backendSystemService.delMailType(id);
        return new ResponseResult<>(SUCCESS);
    }

    @RequestMapping("getMailType")
    public ResponseResult<List<MailType>> getMailType(String account) {

        List<MailType> data = backendSystemService.getMailType(account);
        return new ResponseResult<List<MailType>>(SUCCESS, data);
    }

}
